package com.blue.core.dict;

import com.blue.core.dict.annotation.Dict;

/**
 * 微信类型
 * 
 * @author zhengj
 * @since 1.0 2017年1月14日
 */
@Dict
public enum WechatResponseType
{
	TEXT(1, "文本", Color.BLUE),
	IMAGE(2, "图片", Color.NAVY),
	VOICE(3, "声音", Color.RED),
	VIDEO(4, "视频", Color.MAROON),
	MUSIC(5, "音乐", Color.GRAY), 
	NEWS(6, "图文", Color.FUCHSIA),;
	
	private Integer index;
	private String name;
	private Color color;
	
	WechatResponseType(Integer index, String name, Color color)
	{
		this.index = index;
		this.name = name;
		this.color = color;
	}

	public Integer getIndex()
	{
		return index;
	}

	public String getName()
	{
		return name;
	}

	public Color getColor()
	{
		return color;
	}
	
	public static WechatResponseType getType(String type)
	{
		if (type == null || type.equals(""))
			return null;

		type = type.toUpperCase();
		return WechatResponseType.valueOf(type);
	}

	public static WechatResponseType getIndex(int index)
	{
		for (WechatResponseType t : WechatResponseType.values())
		{
			if (t.getIndex() == index)
				return t;
		}
		return null;
	}
	
	public String getText()
	{
		return this.name().toLowerCase();
	}

	@Override
	public String toString()
	{
		return String.format("<span style=\"color: %s;\">%s</span>", color.name().toLowerCase(), name);
	}

}
